# This file sets:
# - BOOST_INCLUDE_DIRS
# - BOOST_LIB_DIRS
# - BOOST_WT_FOUND  // All dependencies for wt found
# - BOOST_WT_MT_FOUND
# - BOOST_WTHTTP_FOUND // All dependencies for wthttp found
# - BOOST_WTHTTP_MT_FOUND
# - BOOST_SUPPORT_LIBRARIES (should always be added to the boost libs)
# - BOOST_WT_LIBRARIES
#
# Separate compiled boost libraries are also discovered:
# - BOOST_DT_LIB
# - BOOST_FS_LIB
# - BOOST_REGEX_LIB
# - BOOST_PO_LIB
# - BOOST_SIGNALS_LIB
# - BOOST_SYSTEM_LIB
# - BOOST_THREAD_LIB (only if BOOST_MT_FOUND)
# Boost will try to find the same kind (mt or not) of library for all three
# of these libraries. Boost is considered to be found successfully only
# when the libraries are all of the same kind (mt or not). If the mt
# libraries exits, the mt versions will be used unless MULTI_THREADED is
# set to OFF. Otherwise, the non-mt versions will be used.
#

# For starters, see if the cmake-provided scripts are able to find boost
SET(BOOST_WT_FOUND FALSE)
SET(BOOST_WT_MT_FOUND FALSE)
SET(BOOST_WTHTTP_FOUND FALSE)
SET(BOOST_WTHTTP_MT_FOUND FALSE)
SET(BOOST_SUPPORT_LIBRARIES "")

IF(NOT DEFINED Boost_ADDITIONAL_VERSIONS)
  SET(Boost_ADDITIONAL_VERSIONS
  "1.35" "1.36" "1.37" "1.38" "1.39"
  "1.40" "1.41" "1.42" "1.43" "1.44" "1.45" "1.46" "1.47" "1.48" "1.49"
  "1.50" "1.51" "1.52" "1.53" "1.54" "1.55" "1.56" "1.57" "1.58" "1.59"
  "1.60" "1.61" "1.62" "1.63" "1.64" "1.65" "1.66" "1.67" "1.68" "1.69"
  "1.70" "1.71" "1.72" "1.73" "1.74" "1.75" "1.76" "1.77" "1.78" "1.79")
ENDIF(NOT DEFINED Boost_ADDITIONAL_VERSIONS)

SET(Boost_USE_MULTITHREADED ON)

IF(DEFINED BOOST_PREFIX AND NOT DEFINED BOOST_ROOT)
  SET(BOOST_ROOT ${BOOST_PREFIX})
ENDIF(DEFINED BOOST_PREFIX AND NOT DEFINED BOOST_ROOT)

IF(WIN32)
  IF(BOOST_DYNAMIC)
    SET(Boost_USE_STATIC_LIBS OFF)
  ELSE(BOOST_DYNAMIC)
    SET(Boost_USE_STATIC_LIBS ON)
  ENDIF(BOOST_DYNAMIC)
ENDIF(WIN32)

SET(Boost_DEBUG ON)

OPTION(WT_NO_BOOST_RANDOM "For compatibility with older boost versions. Do not enable for boost > 1.45" OFF)
MESSAGE("WT_NO_BOOST_RANDOM is ${WT_NO_BOOST_RANDOM}")

SET(Boost_COMPONENTS
    date_time
    regex
    program_options
    signals
    system
    filesystem
    thread
)
IF(NOT WT_NO_BOOST_RANDOM)
  SET(Boost_COMPONENTS
    ${Boost_COMPONENTS}
    random
  )
ENDIF(NOT WT_NO_BOOST_RANDOM)


FIND_PACKAGE(Boost 1.35
  COMPONENTS
    ${Boost_COMPONENTS}
  REQUIRED
)

IF (Boost_FOUND)
  # Translate variables from official cmake names to internally used names
  SET(BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
  SET(BOOST_LIB_DIRS ${Boost_LIBRARY_DIRS})
  SET(BOOST_DT_LIB ${Boost_DATE_TIME_LIBRARY})
  SET(BOOST_FS_LIB ${Boost_FILESYSTEM_LIBRARY})
  SET(BOOST_REGEX_LIB ${Boost_REGEX_LIBRARY})
  SET(BOOST_PO_LIB ${Boost_PROGRAM_OPTIONS_LIBRARY})
  SET(BOOST_SIGNALS_LIB ${Boost_SIGNALS_LIBRARY})
  SET(BOOST_SYSTEM_LIB ${Boost_SYSTEM_LIBRARY})
  SET(BOOST_THREAD_LIB ${Boost_THREAD_LIBRARY})
  IF(NOT WT_NO_BOOST_RANDOM)
    SET(BOOST_RANDOM_LIB ${Boost_RANDOM_LIBRARY})
  ENDIF(NOT WT_NO_BOOST_RANDOM)

  SET(BOOST_WT_MT_FOUND TRUE)
  SET(BOOST_WT_FOUND TRUE)
  SET(BOOST_WTHTTP_MT_FOUND TRUE)
  SET(BOOST_WTHTTP_FOUND TRUE)

  IF(MSVC)
    # use autolink
    SET(BOOST_WT_LIBRARIES "")
    SET(BOOST_WTHTTP_LIBRARIES "")
  ELSE(MSVC)
    SET(BOOST_WT_LIBRARIES
        ${Boost_THREAD_LIBRARY}
        ${BOOST_RANDOM_LIB}
        ${Boost_REGEX_LIBRARY}
        ${Boost_SIGNALS_LIBRARY}
        ${Boost_SYSTEM_LIBRARY}
        ${Boost_FILESYSTEM_LIBRARY}
        ${Boost_DATE_TIME_LIBRARY})
    SET(BOOST_WTHTTP_LIBRARIES
        ${Boost_THREAD_LIBRARY}
        ${Boost_PROGRAM_OPTIONS_LIBRARY}
        ${Boost_SYSTEM_LIBRARY}
        ${Boost_FILESYSTEM_LIBRARY}
        ${Boost_DATE_TIME_LIBRARY})
  ENDIF(MSVC)
ENDIF (Boost_FOUND)
